package xiaohu.day7.HJ71;

import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main3 {
    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);
        String pattern = scanner.nextLine().trim();
        String string = scanner.nextLine().trim();
        scanner.close();
        boolean result = isMatch(pattern,string);
        System.out.println(result?"true":"false");
    }
    public static boolean isMatch(String pattern,String string){
        int m = pattern.length();
        int n = string.length();
        boolean [][]dp = new boolean[m+1][n+1];
        dp[0][0]=true;
        for(int i = 1 ;i<=m; i++){
            if(pattern.charAt(i-1)=='*'){
                dp[i][0]=dp[i-1][0];
            }
        }
        for(int i = 1 ;i<=m; i++){
            for(int j = 1 ;j<=n;j++){
                char p =pattern.charAt(i-1);
                char s =string.charAt(j-1);
                if(p=='*'){
                    dp[i][j]=dp[i-1][j] ||dp[i][j-1];
                }else if(p=='?'||p==s){
                    dp[i][j]=dp[i-1][j-1];
                }
            }
        }
        return dp[m][n];
    }
}